package game;

import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Point2D;

public class Hud extends GameObject{

	private static final long serialVersionUID = 1L;
	public Point posOriginal; 
	public Rectangle rectColisao;
	
	
	public Hud(int index, Point2D posOriginal, Point2D size, Rectangle rectColisao) 
	{
		super(index, posOriginal, size);
		
		this.rectColisao = rectColisao;
		this.posOriginal = new Point((int)posOriginal.getX(), (int)posOriginal.getY());
	}
	
	public void updateMovimentoHudPlayer(Player player)
	{
		if(player.collision(this.rectColisao))
		{
			if(this.getPosition().getX() + 160 >= 0)
				this.addPosition(new Point2D.Double(-4, 0));			
		}
		else
		{
			this.addPosition(new Point2D.Double(2, 0));
			
			if(this.getPosition().getX() >= this.posOriginal.getX())
				this.setPosition(new Point2D.Double(this.posOriginal.getX(), this.getPosition().getY()));
		}
	}
	
	public void updateMovimentoHudTiro (Player player)
	{
		if(player.collision(this.rectColisao))
		{
			if(this.getPosition().getX() <= Game.screenWidth)
			this.addPosition(new Point2D.Double(4, 0));
		}
		else
		{
			this.addPosition(new Point2D.Double(-2, 0));
			
			if(this.getPosition().getX() <= this.posOriginal.getX())
				this.setPosition(new Point2D.Double(this.posOriginal.getX(), this.getPosition().getY()));
		}
	}
}
